[PATCH] add the binding friendly join_group method to GtkRadioAction
authorJohn (J5) Palmieri <johnp@redhat.com>
Wed, 19 May 2010 19:12:49 +0000 (15:12 -0400)
committerJohn (J5) Palmieri <johnp@redhat.com>
Wed, 19 May 2010 19:16:46 +0000 (15:16 -0400)
* Due to object ownership issues it is impossible to correctly use
  get_group/set_group from a GI binding
* join_group is safer because at the binding level it works with individual
  GtkRadioAction objects and not with the list of objects that gets
  modified in the library

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkradioaction.c
gtk/gtkradioaction.h

index bdf2fb45ecef90d6848ebb6513c5c43b80e562d6..d0d84024f2a082d46ae4011bae7daed9dfc555f6 100644 (file)
@@ -2396,6 +2396,7 @@ GtkRadioAction
 gtk_radio_action_new
 gtk_radio_action_get_group
 gtk_radio_action_set_group
+gtk_radio_action_join_group
 gtk_radio_action_get_current_value
 gtk_radio_action_set_current_value
 <SUBSECTION Standard>
index c83141486242e842d8bb8f13bf338d70f69fbbd5..ff436ba16891fa61f9143a7a3a9f7a2316d958ee 100644 (file)
@@ -2702,6 +2702,7 @@ gtk_radio_action_get_type G_GNUC_CONST
 gtk_radio_action_new
 gtk_radio_action_set_current_value
 gtk_radio_action_set_group
+gtk_radio_action_join_group
 #endif
 #endif
 
index d6363ed1e17d132c6e79ee9e90f28f112dbae1b6..f44c2b546c1a08aa3940eebd952d1c40c8977d4d 100644 (file)
@@ -468,6 +468,61 @@ gtk_radio_action_set_group (GtkRadioAction *action,
     }
 }
 
+/**
+ * gtk_radio_action_join_group:
+ * @action: the action object
+ * @group_source: (allow-none): a radio action object whos group we are 
+ *   joining, or %NULL to remove the radio action from its group
+ *
+ * Joins a radio action object to the group of another radio action object.
+ *
+ * Use this in language bindings instead of the gtk_radio_action_get_group() 
+ * and gtk_radio_action_set_group() methods
+ *
+ * A common way to set up a group of radio actions is the following:
+ * |[
+ *   GtkRadioAction *action;
+ *   GtkRadioAction *last_action;
+ *  
+ *   while (/&ast; more actions to add &ast;/)
+ *     {
+ *        action = gtk_radio_action_new (...);
+ *        
+ *        gtk_radio_action_join_group (action, last_action);
+ *        last_action = action;
+ *     }
+ * ]|
+ * 
+ * Since: 3.0
+ */
+void
+gtk_radio_action_join_group (GtkRadioAction *action, 
+                            GtkRadioAction *group_source)
+{
+  g_return_if_fail (GTK_IS_RADIO_ACTION (action));
+  g_return_if_fail (group_source == NULL || GTK_IS_RADIO_ACTION (group_source));  
+
+  if (group_source)
+    {
+      GSList *group;
+      group = gtk_radio_action_get_group (group_source);
+      
+      if (!group)
+        {
+          /* if we are not already part of a group we need to set up a new one
+             and then get the newly created group */  
+          gtk_radio_action_set_group (group_source, NULL);
+          group = gtk_radio_action_get_group (group_source);
+        }
+
+      gtk_radio_action_set_group (action, group);
+    }
+  else
+    {
+      gtk_radio_action_set_group (action, NULL);
+    }
+}
+
 /**
  * gtk_radio_action_get_current_value:
  * @action: a #GtkRadioAction
index d4a971254c8eb1aea4489305f1748378377de3b8..e0f5df1b3efb8bd4179c5577a62d301018fbd8ca 100644 (file)
@@ -81,6 +81,8 @@ GtkRadioAction *gtk_radio_action_new               (const gchar           *name,
 GSList         *gtk_radio_action_get_group         (GtkRadioAction        *action);
 void            gtk_radio_action_set_group         (GtkRadioAction        *action,
                                                     GSList                *group);
+void            gtk_radio_action_join_group        (GtkRadioAction        *action,
+                                                    GtkRadioAction        *group_source);
 gint            gtk_radio_action_get_current_value (GtkRadioAction        *action);
 void            gtk_radio_action_set_current_value (GtkRadioAction        *action,
                                                     gint                   current_value);